/**
 * 乐器类
 */
var Instruments = {};

Instruments.init = function() {
	Instruments.search();
	
	mui(".data-box").on("tap", "li.to-detail", function(e){
		var me = jQuery(e.target);
		location.href = "detail/?k=" + me.attr("data-id");
	})
}

/**
 * 查询乐器
 */
Instruments.search = function() {
	//获取类别
	jQuery.getJSON(
		"api/v1/getInstruments.json",
		function(json) {
			if(json.success && json.result.length > 0) {
				Instruments.display(json.result);
			}
		}
	);
}

/**
 * 显示乐器列表
 */
Instruments.display = function(data) {
	var h = '';
	for(var i=0, len=data.length; i<len; i++) {
		var item = data[i];
		h += '<li class="mui-table-view-cell mui-media to-detail" data-id="'+ item.id +'">'
		   + '	<a href="javascript:;">'
		   + '		<img class="mui-media-object mui-pull-left" src="'+ item.imgsrc +'">'
		   + '		<div class="mui-media-body">'
		   + '			<p class="title">'+ item.name +'</p>'
		   + '			<p class="detail">'+ item.brand +'</p>'
		   + '		</div>'
		   + '	 </a>'
		   + '</li>';
	}
	jQuery(".data-box").html(h);
}














